package com.java.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.java.base.DaoSupportImpl;
import com.java.domain.UserDo;
import com.java.service.UserService;

@Service
public class UserServiceImpl extends DaoSupportImpl<UserDo> implements
		UserService {

	public List<UserDo> queryAll(Integer isdoc, String mobile) {
		return getSession()
				.createQuery(
						"FROM UserDo where isdoc =:isdoc and mobile like :mobile")
				.setParameter("isdoc", isdoc)
				.setParameter("mobile", "%" + mobile + "%").list();
	}

	public List<UserDo> queryAllMobile(String mobile) {
		return getSession()
				.createQuery("FROM UserDo where mobile like :mobile")
				.setParameter("mobile", "%" + mobile + "%").list();
	}

	public UserDo queryName(String name) {
		List<UserDo> list = getSession()
				.createQuery("FROM UserDo where name =:name")
				.setParameter("name", name).list();
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}
	
	public List<UserDo> queryAllPatient(Integer isdoc) {
		return getSession()
				.createQuery(
						"FROM UserDo where isdoc =:isdoc")
				.setParameter("isdoc", isdoc).list();
	}

}
